import {h} from "vue";
import {NTag} from "naive-ui";

export const columns = [
  {
    title: 'ID',
    key: 'id',
    width: 180,
  },
  {
    title: '题目难度',
    key: 'difficulty',
    width: 100,
    render(row) {
      var type = '';
      var desc = '';
      if(row.difficulty === 0) {
        type = 'success';
        desc = '简单';
      }
      if(row.difficulty === 1) {
        type = 'warning';
        desc = '中等';
      }
      if(row.difficulty === 2) {
        type = 'error';
        desc = '困难';
      }
      // @ts-ignore
      return h(NTag, {
          type: type
        }, {
          default: () => (desc),
        }
      );
    }
  },
  {
    title: '题目标题',
    key: 'name',
    width: 150,
  },
  {
    title: '题目来源',
    key: 'source',
    width: 100,
  },
  {
    title: '状态',
    key: 'status',
    width: 100,
    render(row) {
      return h(
        NTag,
        {
          type: row.status ? 'success' : 'error',
        },
        {
          default: () => (row.status ? '启用' : '禁用'),
        }
      );
    },
  },
  {
    title: '创建人',
    key: 'createBy',
    width: 100,
  },
  {
    title: '创建时间',
    key: 'createTime',
    width: 180,
  },
  {
    title: '更新人',
    key: 'updateBy',
    width: 100,
  },
  {
    title: '更新时间',
    key: 'updateTime',
    width: 180,
  },
];
